package day240519_report.e4;

public class Triangle extends Shape {
    //state
    private double edge1;
    private double edge2;
    private double edge3;

    //constructor

    //behavior
    public double getEdge1() {
        return edge1;
    }

    public double getEdge2() {
        return edge2;
    }

    public double getEdge3() {
        return edge3;
    }

    public Triangle setEdge1(double edge1) {
        this.edge1 = edge1;
        return this;
    }

    public Triangle setEdge2(double edge2) {
        this.edge2 = edge2;
        return this;
    }

    public Triangle setEdge3(double edge3) {
        this.edge3 = edge3;
        return this;
    }

    public double getPerimeter() {
        return getEdge1() + getEdge2() + getEdge3();
    }

    public double getArea() {
        double p = (getEdge1() + getEdge2() + getEdge3()) / 2;
        return Math.sqrt(p * (p - getEdge1()) * (p - getEdge2()) * (p - getEdge3()));//海伦公式
    }

}
